package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.BuyerBean;
import com.project.service.IBuyerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@RequestMapping("buyer")
public class BuyerController {
    @Autowired
    private IBuyerService service;
@RequestMapping("add")
    public String add(Integer supId, String cadre, Integer userId){
    BuyerBean buyerBean = new BuyerBean(supId,cadre);
        service.add(buyerBean,userId);
        return "ok";
    }
@RequestMapping("findByItem")
    public IPage<BuyerBean> findByItem(Integer pageNo, String name, @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate){
    return service.findByItem(pageNo,name,startDate,endDate);
    }
@RequestMapping("findById")
    public BuyerBean findById(Integer id){
    return service.findById(id);
    }
}
